﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FitCalc
{
    public partial class Calc : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            
           double speedVal = 0;
            
            double paceTemp = 0;
            if (speed.Text.Trim().Length > 0)
            {
                if (double.TryParse(speed.Text, out speedVal))
                {
                    RunningTime rt= RunningCalc.SpeedToPace(speedVal);
                    
                    paceMinutes.Text = rt.Minutes.ToString();
                    paceSeconds.Text = rt.Seconds.ToString();
                }
            }
            if (paceMinutes.Text.Trim().Length > 0)
            {

                speed.Text = RunningCalc.PaceToSpeed(new RunningTime(paceMinutes.Text, paceSeconds.Text)).ToString();
 
            }
            
        }
    }
}